<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('工时报表')" />
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12 search-collapse m-b">
                <form id="formId" action="/erp/projectHour/report" method="post">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>节假日：</label>
                                <select name="holidayConfigId"  th:with="type=${@customDictService.selectDictHolidayConfigType()}">
                                    <option th:each="dict : ${type}" th:text="${dict.title}" th:value="${dict.id}" th:selected="${report.getHolidayConfigId() == dict.id}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>开始时间：</label>
                                <input type="text" class="time-input"  id="beginTime" placeholder="请选择开始日期" name="beginDate" th:value="${#dates.format(report.getBeginDate(), 'yyyy-MM-dd')}"/>
                                <span>-</span>
                                <input type="text" class="time-input"  id="endTime" placeholder="请选结束时日期" name="endDate" th:value="${#dates.format(report.getEndDate(), 'yyyy-MM-dd')}"/>
                                <span><a  onclick="prevWeek()">上周</a> <a  onclick="nextWeek()">下周</a></span>

                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="submitHandler()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
        </div>
        <div class="row report-info">
            <div class="col-sm-6">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3 class="m-b-md">汇总工时信息</h3>
                        <div class="stat-percent font-bold text-info">[[${report.getNeedDays()}]] 人天</div>
                        <small>应出勤天数</small>
                    </div>
                    <div class="ibox-content">
                        <div class="stat-percent font-bold text-info">[[${report.getNormalWorkDays()}]] 人天</div>
                        <small>正常项目工时</small>
                    </div>
                    <div class="ibox-content">
                        <div class="stat-percent font-bold text-info">[[${report.getFreeWorkDays()}]] 人天</div>
                        <small>空闲工时</small>
                    </div>
                    <div class="ibox-content">
                        <div class="stat-percent font-bold text-info">[[${report.getMaintainWorkDays()}]] 人天</div>
                        <small>运维工时</small>
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3 class="m-b-md">其他信息</h3>
                        <div class="stat-percent font-bold text-danger">[[${report.getAbnormalCount()}]] 人次</div>
                        <small>工时异常人次</small>
                    </div>
                    <div class="ibox-content">
                        <div class="stat-percent font-bold text-danger">[[${report.getAbnormalDays()}]] 人天</div>
                        <small>工时异常小时数</small>
                    </div>
                    <div class="ibox-content">
                        <div class="stat-percent font-bold text-danger">[[${report.getOvertimeDays()}]] 人天</div>
                        <small>加班人天</small>
                    </div>
                    <div class="ibox-content">
                        <div class="stat-percent font-bold text-danger">[[${report.getLeaveDays()}]] 人天</div>
                        <small>请假人天</small>
                    </div>
                </div>
            </div>
        </div>
        <div class="row report-info">
            <div class="col-sm-4">
                <div class="ibox">
                    <div class="ibox-content">
                        <h5>出勤率</h5>
                        <h2>[[${report.getWorkHourRate()}]]%</h2>
                        <div class="progress progress-mini">
                            <div id="progress-bar" th:style="'width: ' + ${report.getWorkHourRate() } + '%'" class="progress-bar"></div>
                        </div>

                        <div class="m-t-sm small">应出勤 [[${report.getNeedHour()}]] 小时</div>
                        <div class="m-t-sm small">实际出勤 [[${report.getTotalWorkHours()}]] 小时</div>
                    </div>
                </div>
            </div>

            <div class="col-sm-2">
                <div class="ibox">
                    <div class="ibox-content">
                        <h5>工时类型占比</h5>
                        <div class="text-center">
                            <div id="free"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-sm-2">
                <div class="ibox">
                    <div class="ibox-content">
                        <h5>请假工时占比</h5>
                        <div class="text-center">
                            <div id="leave"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="ibox">
                    <div class="ibox-content">
                        <h5>加班工时占比</h5>
                        <div class="text-center">
                            <div id="overtime"></div>
                        </div>
                    </div>
                </div>
            </div>


            <div class="col-sm-2">
                <div class="ibox">
                    <div class="ibox-content">
                        <h5>异常工时百分比</h5>
                        <div class="text-center">
                            <div id="abnormal"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<!--        <div class="row">-->
<!--            <div class="col-sm-12 select-table table-striped">-->
<!--                <table id="bootstrap-table"></table>-->
<!--            </div>-->
<!--        </div>-->
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: peity-js" />
    <th:block th:include="include :: sparkline-js" />
    <script type="text/javascript">
	    $(document).ready(function () {
            var leaveHour =  [[${report.getLeaveDays()}]];
            var leaveCount = [[${report.getLeaveCount()}]];
            var overtimeHours =  [[${report.getOvertimeDays()}]];
            var leaveCount = [[${report.getOvertimeCount()}]];
            var normalHours = [[${report.getNormalWorkDays()}]];
            var freeHours = [[${report.getFreeWorkDays()}]];
            var maintainHours = [[${report.getMaintainWorkDays()}]];
            var needHours = [[${report.getNeedDays()}]];
            var totalHours = 0 + normalHours + freeHours + maintainHours;
            var abnormalDays = [[${report.getAbnormalDays()}]];

	        $("#leave").sparkline([leaveHour, totalHours], {
	            type: 'pie',
	            height: '100',
	            sliceColors: ['#1ab394', '#F5F5F5']
	        });
	
	        $("#overtime").sparkline([overtimeHours, totalHours - overtimeHours], {
	            type: 'pie',
	            height: '100',
	            sliceColors: ['#1ab394', '#F5F5F5']
	        });
	
	        $("#free").sparkline([normalHours, maintainHours, freeHours], {
	            type: 'pie',
	            height: '100',
	            sliceColors: ['#1ab394', '#1717ea','#c40b1b']
	        });
            $("#abnormal").sparkline([abnormalDays, needHours - abnormalDays], {
                type: 'pie',
                height: '100',
                sliceColors: ['#ed5565', '#F5F5F5']
            });
	

	    });

	    
	    $(function() {

	
	        var updatingChart = $(".updating-chart").peity("line", { fill: '#1ab394',stroke:'#169c81', width: 64 })
	
	        setInterval(function() {
	            var random = Math.round(Math.random() * 10)
	            var values = updatingChart.text().split(",")
	            values.shift()
	            values.push(random)
	
	            updatingChart
	                .text(values.join(","))
	                .change()
	        }, 1000);
	    });

        function prevWeek()
        {
            var date = new Date($('#beginTime').val());
            $('#endTime').val($('#beginTime').val());
            date.setDate(date.getDate() - 7);
            $('#beginTime').val(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate());
        }
        function nextWeek()
        {
            var date = new Date($('#beginTime').val());
            date.setDate(date.getDate() + 7);
            $('#beginTime').val(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate());
            date.setDate(date.getDate() + 7);
            $('#endTime').val(date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate());
        }

        function submitHandler() {
            $('#formId').submit();
        }
    </script>
</body>
</html>